<template>
  <div v-cloak>
    <Meta pagealias="campus" />
    <!-- 头部 -->
    <Head>校招</Head>
    <!-- 轮播图 -->
    <swiper
      :slides-per-view="3"
      :space-between="50"
      :pagination="{ clickable: true }"
      :options="bannerSwiperOption"
      class="banner_sw_con"
      @click-slide="handleClickSlide"
      v-if="ad_list['QS_campus_top_slide@mobile']!==undefined && $store.state.swiperLoaded"
    >
      <swiper-slide class="banner_sw_side" v-for="(item ,index) in ad_list['QS_campus_top_slide@mobile']" :key="index">
        <a class="sw_link">
          <img :src="item.image_src" alt="" />
        </a>
      </swiper-slide>
      <div class="swiper-pagination banner_sw_pag" slot="pagination"></div>
    </swiper>

    <!-- 菜单 -->
    <CampusMenu></CampusMenu>

    <!-- 公告 -->
    <div class="notice_wrapper">
      <div class="notice J_notice">
        <ul class="notice_list" :class="{ 'animate-up': animateUp }">
          <li class="notice_li" v-for="(i) in dataset.notice_list" :key="i.id">
            <a class="notice_link substring" href="javascript:;" @click="notice_jump(i.id)">{{i.title}}</a>
          </li>
        </ul>
      </div>
    </div>

    <div class="i_wrapper">
      <!-- 校招名企 -->
      <div class="famous_com">
        <IndexTitle>
          <span class="left idx_text" slot="title_text">校招名企</span>
        </IndexTitle>
        <div class="famous_list">
          <div class="famous_item" v-for="(item, index) in ad_list['QS_campus_famous@mobile']" :key="index" @click="famous_jump(item)">
            <a class="img_link">
              <img :src="item.image_src" alt="">
            </a>
            <a class="item_link substring">{{item.bottom_text}}</a>
          </div>
        </div>
      </div>
      <!-- 校招宣讲会 -->
      <div class="meeting_1">
        <IndexTitle>
          <span class="left idx_text" slot="title_text">校招宣讲会</span>
          <a class="idx_more right" slot="title_more" @click="preachJump()">更多>></a>
        </IndexTitle>
        <div class="meeting_list_1">
          <div class="meeting_list_wrapper clearfix">
            <div class="meeting_school left" v-for="(item) in dataset.school_list" :key="item.id" @click="preachJumpList(item.id)">
              <div class="left school_img">
                <img
                  :src="item.logo_url"
                  alt=""
                />
              </div>
              <div class="left school_text">
                <a class="s_text_1 substring">{{item.school_name}}</a>
                <p class="s_text_2 substring">近期有<span>{{item.total}}</span>场宣讲会</p>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 校园双选会 -->
      <div class="double_meeting">
        <IndexTitle>
          <span class="left idx_text" slot="title_text">校园双选会</span>
          <a class="idx_more right" @click="electionJump()">更多>></a>
          <router-link class="idx_more right" :to="'/campus/election'" slot="title_more">更多>></router-link>
        </IndexTitle>
        <div class="double_meeting_list">
          <div class="meeting_item">

            <div class="d_meeting_info" v-for="(item) in dataset.election_list" :key="item.id" @click="electionListJump(item.id)">
              <div class="top_text">
                <img src="../../assets/images/campus/conduct-end.png" alt="0" class="img" v-if="item.score ===0" />
                <img src="../../assets/images/campus/conduct-start.png" alt="1" class="img" v-if="item.score ===1" />
                <img src="../../assets/images/campus/conduct-progress.png" alt="2" class="img" v-if="item.score ===2" />
                <p class="substring">{{item.school_name}}</p>
                <p class="substring">{{item.subject}}</p>
              </div>
              <div class="bot_text">
                <p class="substring">举办时间:{{item.starttime | timeFilter }} - {{item.endtime | timeFilter}}</p>
                <p class="substring">举办地址:{{item.address}}</p>
              </div>
            </div>

          </div>
        </div>
      </div>

      <!-- 全职 -->
      <div class="full_time">
        <IndexTitle>
          <span class="left idx_text" slot="title_text">全职</span>
          <router-link class="idx_more right" :to="'/campus/job'" slot="title_more">更多>></router-link>
        </IndexTitle>
        <div class="full_time_list">
          <FullTimeItem :dataset="dataset.job_list"></FullTimeItem>
          <div class="height2"></div>
        </div>
      </div>
    </div>
    <div class="height"></div>
  <BottomNav/>
  </div>
</template>

<script>
import BottomNav from './components/BottomNav.vue'
import CampusMenu from './components/CampusMenu.vue'
import FullTimeItem from './components/FullTimeItem.vue'
import IndexTitle from './components/IndexTitle.vue'
import { parseTime } from '@/utils/index'
import http from '@/utils/http.js'
import api from '@/api.js'
export default {
  data () {
    return {
      // banner 轮播图
      bannerSwiperOption: {
        loop: true,
        initialSlide: 0,
        pagination: {
          el: '.banner_sw_pag'
        },
        autoplay: {
          delay: 2500,
          stopOnLastSlide: false,
          disableOnInteraction: false
        },
        speed: 800
      },
      // 公告轮播
      animateUp: false,
      timer: null,
      dataset: {},
      ad_list: {}
    }
  },
  components: {
    BottomNav,
    CampusMenu,
    FullTimeItem,
    IndexTitle
  },
  mounted () {
    this.timer = setInterval(this.scrollAnimate, 3000)
    this.fetchData()
  },
  filters: {
    timeFilter (timestamp) {
      return parseTime(timestamp, '{y}-{m}-{d}')
    }
  },
  methods: {
    // 公告滚动
    scrollAnimate () {
      this.animateUp = true
      setTimeout(() => {
        this.dataset.notice_list.push(this.dataset.notice_list[0])
        this.dataset.notice_list.shift()
        this.animateUp = false
      }, 500)
    },
    // 公告列表跳转
    notice_jump (id) {
      this.$router.push('/campus/notice/' + id)
    },
    // 校招宣讲会更多跳转
    preachJump () {
      this.$router.push('/campus/school')
    },
    // 校招宣讲会列表跳转
    preachJumpList (id) {
      this.$router.push('/campus/school/' + id)
    },
    // 校园双选会更多跳转
    electionJump () {
      this.$router.push('/campus/election')
    },
    // 校园双选会列表跳转
    electionListJump (id) {
      this.$router.push('/campus/election/' + id)
    },
    handleClickSlide (index, reallyIndex) {
      this.handlerClick(this.ad_list['QS_campus_top_slide@mobile'][reallyIndex])
    },
    famous_jump (data) {
      this.handlerClick(data)
    },
    fetchData () {
      http.get(api.campus_index).then((res) => {
        res.data.data.school_list = res.data.data.school_list.slice(0, 9)
        this.dataset = res.data.data
      })
      http.post(api.campus_ad_list, {
        alias: [
          'QS_campus_top_slide@web',
          'QS_campus_famous@web',
          'QS_campus_top_slide@mobile',
          'QS_campus_famous@mobile'
        ]
      }).then((res) => {
        this.ad_list = res.data.items
      }).catch(() => {})
    },
    handlerClick (item) {
      if (item.link_url) {
        window.location.href = item.link_url
      } else if (item.company_id > 0) {
        this.$router.push('/company/' + item.company_id)
      } else if (item.inner_link) {
        let path = ''
        let params_type = 'query'
        switch (item.inner_link) {
          case 'index':
            path = '/'
            break
          case 'joblist':
            path = '/joblist'
            break
          case 'jobshow':
            path = '/job'
            params_type = 'params'
            break
          case 'resumelist':
            path = '/resumelist'
            break
          case 'noticeshow':
            path = '/notice'
            params_type = 'params'
            break
          case 'articlelist':
            path = '/newslist'
            break
          case 'articleshow':
            path = '/news'
            params_type = 'params'
            break
          default:
            path = ''
            break
        }
        if (path != '') {
          if (item.inner_link_params > 0) {
            if (params_type == 'query') {
              path = path + '?id=' + item.inner_link_params
            } else {
              path = path + '/' + item.inner_link_params
            }
          }
          this.$router.push(path)
        }
      }
    }
  },
  destroyed () {
    clearInterval(this.timer)
  }
}
</script>

<style lang="scss" scoped>
.height{
  height:53px;
}
.height2 {
  height: 25px;
}
/* 轮播图 */
.banner_sw_con {
  margin: 0 17px;
  height: 110px;
  overflow: hidden;
  position: relative;
  border-radius: 10px;
}

.banner_sw_con {
  white-space: nowrap;
  font-size: 0;
}

.banner_sw_con  .banner_sw_side {
  width: 341.5px;
  height: 111px;
  display: inline-block;
}

.banner_sw_con  .swiper-wrapper .banner_sw_side .sw_link {
  width: 341.5px;
  height: 111px;
  display: block;
}

.banner_sw_con .swiper-wrapper  .banner_sw_side .sw_link img {
  width: 341.5px;
  height: 111px;
}

>>>.banner_sw_con .swiper-pagination {
  width: auto;
  position: absolute;
  right: 10px;
  text-align: center;
  height: 7.5px;
  font-size: 0;
  z-index: 99;
  bottom: 7.5px;
  left:unset;
}

>>>.banner_sw_con .swiper-pagination .swiper-pagination-bullet {
  width: 7.5px;
  height: 7.5px;
  display: inline-block;
  background-color: #fff;
  border-radius: 50%;
  margin-left: 5px;
  opacity: 0.8;
}

>>>.banner_sw_con .swiper-pagination .swiper-pagination-bullet-active {
  width: 25px;
  border-radius: 5px;
  opacity: 1;
}

/* 公告 */

.notice_wrapper {
  padding: 25px 9px 5px;
  background-image: linear-gradient(#fff, #f9f9fb);
}

.notice {
  height: 30px;
  border-radius: 15px;
  padding-left: 38.5px;
  background: url(../../assets/images/campus/notice_icon.png) no-repeat 10.5px center/15.5px 14.5px #f4f6f5;
  overflow: hidden;
}

.notice  .animate-up {
  transition: all 0.5s ease-in-out;
  transform: translateY(-30px);
}

.notice .notice_list {
  width:300px;
}
.notice .notice_list .notice_li .notice_link {
  color: #000000;
  font-size: 13px;
  display: block;
  height: 30px;
  line-height: 30px;
}

/* 内容 */

.i_wrapper {
  padding: 0 9px;
  background: #f9f9fb;
}

/* 校招名企 */
.famous_com .famous_list{
  overflow: auto;
  font-size: 0;
  white-space:nowrap;
  margin-bottom: 5px;
}

.famous_com .famous_list::-webkit-scrollbar{
  display: none;
}

.famous_list .famous_item{
  width:156px;
  height: 90px;
  background-color: #fff;
  margin-right: 10px;
  display: inline-block;
  vertical-align: middle;
}
.famous_list .famous_item .item_link{
  display: block;
  font-size: 13px;
  color: #222222;
  text-align: center;
  margin:  0 10px;
}
.famous_list .famous_item .img_link{
  width: 100%;
  height: 64px;
  position: relative;
  display: block;
}
.famous_list .famous_item .img_link img{
  width:130px ;
  height: 50px;
  position:absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  margin: auto;
}

.famous_list .famous_item:last-child{
  margin-right: 0;
}

/* 校招宣讲会 */

.meeting_1 .meeting_list_1 {
  width: 358px;
  overflow-x: scroll;
  margin: 0 auto;
}

.meeting_1 .meeting_list_1::-webkit-scrollbar {
  display: none;
}

.meeting_list_1 .meeting_list_wrapper {
  width:711px;
  white-space: nowrap;
}

.meeting_list_1 {
  display: inline-block;
  margin-right: 9.5px;
}

.meeting_list_1 .meeting_school {
  width: 227px;
  height: 70px;
  background-color: #fff;
  border-radius: 5px;
  margin-bottom: 10px;
  box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.1);
  padding: 10px 8.5px;
  margin-right: 15px;
}

.meeting_list_1 .meeting_school:nth-child(3n) {
  margin-right: 0;
}

.meeting_school .school_img {
  width: 49px;
  height: 49px;
  border-radius: 50%;
  position: relative;
  margin-right: 10px;
}

.meeting_school .school_img img {
  max-width: 47.5px;
  max-height: 47.5px;
  border-radius: 50%;
  display: block;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  margin: auto;
}

.meeting_school .school_text {
  width: 149px;
}

.meeting_school .school_text .s_text_1 {
  color: #444444;
  font-size: 16px;
  font-weight: bold;
  display: block;
  margin-bottom: 5px;
}

.meeting_school .school_text .s_text_2 {
  color: #999999;
  font-size: 14px;
}

.meeting_school .school_text .s_text_2 span {
  color: #01c67e;
}

/* 校园双选会 */

.double_meeting .double_meeting_list {
  overflow-x: auto;
  padding: 0px 0 0px 10px;
  margin-bottom: 5px;
}

.double_meeting .double_meeting_list::-webkit-scrollbar {
  display: none;
}

.double_meeting_list .meeting_item {
  white-space: nowrap;
    font-size: 0;
}

.meeting_item .d_meeting_info {
  width: 160.5px;
  height: 92px;
  margin-right: 7px;
  border-radius: 10px;
  position: relative;
  display: inline-block;
  vertical-align: middle;
  color: #fff;
}

.meeting_item .d_meeting_info .top_text {
  text-align: center;
  font-size: 12px;
  padding: 6.5px 0;
  border-bottom: 1px dashed rgba(225, 225, 225, 0.5);
  margin: 0 22px;
  position: relative;

}

.meeting_item .d_meeting_info .top_text p{
  text-overflow: unset;
}

.meeting_item .d_meeting_info .top_text .img {
  position: absolute;
  right: -22px;
  top: 0;
  width: 20px;
  height:40px;
  border-radius: 0 10px 0 0;
  font-size: 7px;
  line-height: 31.5px;
}

.meeting_item .d_meeting_info .bot_text {
  font-size: 9px;
  padding: 8.5px 0 8.5px 8.5px;
}

.meeting_item .d_meeting_info:nth-child(even) {
  background: url(../../assets/images/campus/double_meeting_2.png) no-repeat center center/160.5px 92px;
}

.meeting_item .d_meeting_info:nth-child(odd) {
  background: url(../../assets/images/campus/double_meeting_1.png) no-repeat
    center center/160.5px 92px;
}

.full_time_list .full_time_item {
  background-color: #fff;
  height: 106px;
  border-radius: 10px;
  margin-bottom: 10px;
  padding: 17px 9px 15px 12px;
}
.full_time_list .full_time_item .item_img {
  width: 48px;
  height: 48px;
  border: 1px solid #e6edea;
  border-radius: 10px;
  margin-right: 12.5px;
  position: relative;
}
.full_time_item .item_img img {
  max-width: 46.5px;
  max-height: 46.5px;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  margin: auto;
}
.full_time_item .item_info {
  width: 271.5px;
  position: relative;
}
.full_time_item .item_info .job_name {
  display: block;
  max-width:200px;
  color: #333333;
  font-size: 16px;
  margin-bottom: 10px;
}
.full_time_item .item_info .salary {
  color: #fc4700;
  font-size: 13px;
  font-weight: bold;
  position: absolute;
  right: 0;
  top: 2.5px;
}
.full_time_item .item_info .com_name {
  color: #444444;
  font-size: 14px;
  margin-bottom: 10px;
}

.full_time_item .item_info .oth_list {
  max-width:200px;
  color: #999999;
  font-size: 0;
}
.full_time_item .item_info .oth_list .oth_item {
  font-size: 13px;
  margin-right: 12.5px;
  position: relative;
}
.full_time_item .item_info .oth_list .oth_item::after {
  content: "";
  width: 1px;
  height: 10.5px;
  background-color: #cacaca;
  position: absolute;
  right: -6.5px;
  top: 50%;
  transform: translateY(-50%);
}

.full_time_item .item_info .oth_list .oth_item:last-child:after {
  display: none;
}
.full_time_item .item_info .date {
  color: #d0d0d0;
  font-size: 13px;
  position: absolute;
  right: 0;
  bottom: 1px;
}
</style>
